package com.ymatou.app.rec.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.app.rec.parameter.SearchPcProductBean;
import com.ymatou.app.rec.service.SearchPcProductCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P2;
import com.ymt.utils.tag.P3;
/**
*Pc端商品搜索接口
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_SearchPcProduct{
	private static  SearchPcProductBean searchpcproductBean;
	private static  SearchPcProductCall searchpcproductCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("Pc端商品搜索接口");
		try{
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	@Before
	public void caseUp() {
		searchpcproductBean=new SearchPcProductBean();
		searchpcproductCall=new SearchPcProductCall();
		
		searchpcproductBean.setFl("sproductid,ibrandid,bgcategoryarray");//需要返回的商品值需要在此传入
		searchpcproductBean.setPlatform("pc");//默认传pc
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(searchpcproductCall.getOpurl());
		
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_SearchPcProduct_001() {
		Logger.start(true,"Pc端商品搜索接口调用成功");
		try {
			//TODO 补全case代码
			//org.junit.Assert.fail();
			searchpcproductBean.setFilter(null);//过滤品牌和类目的参数
			searchpcproductBean.setQuery("keyword(mixkeyword,测试)"); //过滤商品名
			
			searchpcproductCall.setData(searchpcproductBean);
			searchpcproductCall.callService();			
			Logger.comment("searchpcproductCall send:" + searchpcproductCall.getEntityString());
			Logger.comment("searchpcproductCall response:" + searchpcproductCall.getReturnData());
			
			Logger.verifyEquals("OK",searchpcproductCall.getSuccess(), "接口调用是否成功");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SearchPcProduct_002() {
		Logger.start(true,"Pc端商品搜索接口超时");
		try {
			//TODO 补全case代码
			//org.junit.Assert.fail("异常");
			searchpcproductBean.setFilter(null);//过滤品牌和类目的参数
			searchpcproductBean.setQuery("keyword(mixkeyword,测试)"); //过滤商品名
			
			searchpcproductCall.setData(searchpcproductBean);
			searchpcproductCall.callService();			
			Logger.comment("searchpcproductCall send:" + searchpcproductCall.getEntityString());
			Logger.comment("searchpcproductCall response:" + searchpcproductCall.getReturnData());
			Logger.verifyEquals(false,searchpcproductCall.getTimeOut(), "PC端商品搜索接口是否超时");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_SearchPcProduct_003() {
		Logger.start(true,"Pc端商品搜索接口按类目过滤");
		try {
			//TODO 补全case代码
			//org.junit.Assert.fail();
			searchpcproductBean.setQuery(null); //过滤商品名
			//
			searchpcproductBean.setFilter("and(term(bgcategoryarray,170105))");//过滤类目的参数 170105
			
			searchpcproductCall.setData(searchpcproductBean);
			searchpcproductCall.callService();			
			Logger.comment("searchpcproductCall send:" + searchpcproductCall.getEntityString());
			Logger.comment("searchpcproductCall response:" + searchpcproductCall.getReturnData());
			Logger.verifyEquals("OK",searchpcproductCall.getSuccess(), "接口调用是否成功");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_SearchPcProduct_004() {
		Logger.start(true,"Pc端商品搜索接口按品牌过滤");
		try {
			//TODO 补全case代码
		//	org.junit.Assert.fail();
			searchpcproductBean.setQuery(null); //过滤商品名
			searchpcproductBean.setFilter("and(term(ibrandid,10098))");//过滤品牌和类目的参数 10098
			
			searchpcproductCall.setData(searchpcproductBean);
			searchpcproductCall.callService();			
			Logger.comment("searchpcproductCall send:" + searchpcproductCall.getEntityString());
			Logger.comment("searchpcproductCall response:" + searchpcproductCall.getReturnData());
			Logger.verifyEquals("OK",searchpcproductCall.getSuccess(), "接口调用是否成功");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_SearchPcProduct_005() {
		Logger.start(true,"Pc端商品搜索接口按商品名、类目、品牌搜索");
		try {
			//TODO 补全case代码
			//org.junit.Assert.fail();
			searchpcproductBean.setQuery("keyword(mixkeyword,测试)"); //过滤商品名
			searchpcproductBean.setFilter("and(term(ibrandid,10098),term(bgcategoryarray,170105))");//过滤品牌和类目的参数 10098
			searchpcproductCall.setData(searchpcproductBean);
			searchpcproductCall.callService();			
			Logger.comment("searchpcproductCall send:" + searchpcproductCall.getEntityString());
			Logger.comment("searchpcproductCall response:" + searchpcproductCall.getReturnData());
			Logger.verifyEquals("OK",searchpcproductCall.getSuccess(), "接口调用是否成功");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SearchPcProduct_006() {
		Logger.start(true,"Pc端商品搜索接口店铺内搜索过滤");
		try {
			//TODO 补全case代码
			//org.junit.Assert.fail();
			searchpcproductBean.setFilter("and(term(iuserid,1377367))");
			
			searchpcproductCall.setData(searchpcproductBean);
			searchpcproductCall.callService();			
			Logger.comment("searchpcproductCall send:" + searchpcproductCall.getEntityString());
			Logger.comment("searchpcproductCall response:" + searchpcproductCall.getReturnData());
			Logger.verifyEquals("OK",searchpcproductCall.getSuccess(), "接口调用是否成功");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	/*@Test
	@Category(P3.class)
	@TestCase
	public void Tc_SearchPcProduct_007() {
		Logger.start(true,"Pc端商品搜索接口返回记录数错误");
		try {
			//TODO 补全case代码
			org.junit.Assert.fail();
			searchpcproductCall.setData(searchpcproductBean);
			searchpcproductCall.callService();			
			Logger.comment("searchpcproductCall send:" + searchpcproductCall.getEntityString());
			Logger.comment("searchpcproductCall response:" + searchpcproductCall.getReturnData());
		} catch (Exception e) {
			Logger.fail(e);
		}
	}*/
}